import request from '@/utils/request';
import type { Department, PickDepartment, Simple } from '@/type/DepartmentType';
import type { ResponseType } from '@/type/ResponseType';


enum Enum {
  fetchDepartments = '/company/department',
  deleteDepartmentsAPI = '/company/department',
  addDepartmentsAPI = '/company/department',
  updateDepartmentsAPI = '/company/department',
  findDepartmentsAPI = '/company/department',
  fetchSimpleAPI = '/sys/user/simple'
}

/**
 * @description 获取-部门列表的接口
 * */
export const fetchDepartmentsAPI = () => request.get<Department[], ResponseType<Department[]>>(Enum.fetchDepartments);

/**
 * @description 删除-部门的接口
 * */
export const deleteDepartmentsAPI = (id: string) => request.delete<null, ResponseType<null>>(`${Enum.deleteDepartmentsAPI}/${id}`);


/**
 * @description 修改-部门详情的接口
 * */
export const updateDepartmentsAPI = (data: Department) => request.put<string | null, ResponseType<string|null>>(`${Enum.updateDepartmentsAPI}/${data.id}`, data);

/**
 * @description 查询-部门详情的接口
 * */
export const findDepartmentsAPI = (id: string) => request.get<Department, ResponseType<Department>>(`${Enum.findDepartmentsAPI}/${id}`);


/**
 * @description 新增-部门的接口
 * */
export const addDepartmentsAPI = (data: PickDepartment) => request.post<{ id: number }, ResponseType<{ id: number }>>(`${Enum.addDepartmentsAPI}`, data);


/**
 * @description 获取-部门负责人列表的接口
 * */
export const fetchSimpleAPI = () => request.get<Simple[], ResponseType<Simple[]>>(Enum.fetchSimpleAPI);
